#include "QNode.h"

QNode::QNode()
{

}

QNode::QNode(RECT rect, double id)
{
	_rect = rect;
	_id = id;
}

QNode::QNode(vector<int> &listNumber, map<int, GameObject*> &listObjects)
{
	int n = listNumber.size();

	_id = listNumber[0];

	_rect.left = listNumber[1];
	_rect.top = listNumber[2];
	_rect.right = _rect.left + listNumber[3];
	_rect.bottom = _rect.top - listNumber[4];

	for (int i = 5; i < n; i++)
	{
		ListObjs.push_back(listObjects.find(listNumber[i])->second);
	}
}

QNode::~QNode()
{
	int n = ListObjs.size();

	for (int i = 0; i < n; i++)
	{
		if (ListObjs[i]->PosX() > 0)
		{
			delete ListObjs[i];
		}
	}

	if (ChildNode.size() == 0) return;

	for (int i = 0; i < ChildNode.size(); i++)
	{
		delete ChildNode[i];
	}
}